<%@ page contentType="text/html;charset=UTF-8" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
<c:set var="ctx" value="${pageContext.request.contextPath}"/>
<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <%@ include file="/common/dxp/include/common-base.jsp" %>
    <title>报文格式管理</title>
    <!-- Tell the browser to be responsive to screen width -->
    <meta content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" name="viewport">
</head>

<!-- Part 一、 以下是body主体内容的模块区域 -->
<body class="hold-transition ${sysColor} sidebar-mini">
<div class="wrapper">

    <!-- top start -->
    <%@include file="/common/dxp/top.jsp" %>
    <!-- top end -->
    <!-- left start -->
    <%@include file="/common/dxp/left.jsp" %>
    <!-- left end-->

    <div class="content-wrapper">
        <!-- Main start -->
        <section class="content">
            <div id="div_hidden_content" class="hidden">
                <!-- temp="delForm_hidden" start -->
                <div id="delForm_hidden" style="display:none;">
                    <input type="hidden" name="pageName" value="dx-msg-format-set"/>
                    <input type="hidden" name="formName" value="delForm"/>
                </div>
                <!-- temp="delForm_hidden" end -->

                <form id="searchForm" action="javascript:;">
                    <div style="display:none;">
                        <input type="hidden" name="pageName" value="dx-msg-format-set"/>
                        <input type="hidden" name="formName" value="searchForm"/>
                        <input type="hidden" name="dxMsgFormatSet.w_interfaceId" class="param_interfaceId" value=""/>
                        <input type="" name="dxMsgFormatSet.w_msgType" value=""/>
                    </div>
                </form>

            </div>
            <div class="row">
                <div class="col-xs-12">

                    <!------- 列表 start -------->
                    <div class="box  box-solid">
                        <!--列表title  start -->
                        <div class="box-header with-border">
                            <table class="table" style="margin-bottom:0px;">
                                <tbody>
                                <tr>
                                    <td class="w90">接口编号：</td>
                                    <td colspan="3"><span class="param_interfaceCode"></span>-<span class="param_interfaceName"></span></td>
                                </tr>
                                <tr>
                                    <td class="w90">请求方式：</td>
                                    <td class="w400 param_requestWay"></td>
                                    <td class="w90"><span contenteditable="true">报文格式：</span></td>
                                    <td class="param_interfaceRMFT"></td>
                                </tr>
                                </tbody>
                            </table>
                            <div class="box-tools pull-right">
                                <button onclick="getTableDataAll();" class="btn btn-default btn-box-tool" type="button"><i class="fa fa-refresh"></i> 刷新数据</button>
                                <button onclick="goBack();" class="btn btn-default btn-box-tool" type="button"><i class="fa fa-reply"></i> 返回上级</button>
                            </div>
                        </div>
                        <div class="box-body mytab2">
                            <ul class="nav nav-tabs">
                                <li class="active"><a href="#tab_req_params" data-toggle="tab">请求参数(Request Params)</a></li>
                                <li><a href="#tab_req_header" data-toggle="tab">请求头(Request Headers)</a></li>
                                <li><a href="#tab_req_body" data-toggle="tab">请求报文体(Request Body)</a></li>
                                <li><a href="#tab_resp_body" data-toggle="tab">响应报文体(Response Body)</a></li>
                            </ul>
                            <div class="tab-content">
                                <div class="tab-pane active" id="tab_req_params">
                                    <table id="table_req_params" data-msg-type="params" class="table table-bordered table-hover">
                                        <thead>
                                        <tr>
                                            <th data-field="paramEname" data-formatter="fieldShowFormatter">参数英文名(key)</th>
                                            <th data-field="paramCname" data-formatter="fieldShowFormatter">参数中文名(name)</th>
                                            <th data-field="defValue" data-formatter="fieldShowFormatter">参数默认值(value)</th>
                                            <th data-field="infoId" data-formatter="optFormatter">操作 <button data-info-id="0" title="增加子节点" onclick="addNodeRows(this)" class="btn btn-default btn-xs"><i class="fa fa-plus-circle"></i> 增加子节点</button></th>
                                        </tr>
                                        </thead>
                                        <tbody class="box-min-table"> </tbody>
                                    </table>
                                </div>
                                <div class="tab-pane" id="tab_req_header">
                                    <table id="table_req_header" data-msg-type="header" class="table table-bordered table-hover">
                                        <thead>
                                        <tr>
                                            <th data-field="paramEname" data-formatter="fieldShowFormatter">参数英文名(key)</th>
                                            <th data-field="paramCname" data-formatter="fieldShowFormatter">参数中文名(name)</th>
                                            <th data-field="defValue" data-formatter="fieldShowFormatter">参数默认值(value)</th>
                                            <th data-field="infoId" data-formatter="optFormatter">操作 <button data-info-id="0" title="增加子节点" onclick="addNodeRows(this)" class="btn btn-default btn-xs"><i class="fa fa-plus-circle"></i> 增加子节点</button></th>
                                        </tr>
                                        </thead>
                                        <tbody class="box-min-table"> </tbody>
                                    </table>
                                </div>
                                <div class="tab-pane" id="tab_req_body">
                                    <table id="table_req_body" data-msg-type="req" class="table table-bordered table-hover">
                                        <thead>
                                        <tr>
                                            <th data-field="paramEname" data-formatter="fieldShowFormatter">参数英文名(key)</th>
                                            <th data-field="paramCname" data-formatter="fieldShowFormatter">参数中文名(name)</th>
                                            <th data-field="defValue" data-formatter="fieldShowFormatter">参数默认值(value)</th>
                                            <th data-field="infoId" data-formatter="optFormatter">操作</th>
                                        </tr>
                                        </thead>
                                        <tbody class="box-min-table"> </tbody>
                                    </table>
                                </div>
                                <div class="tab-pane" id="tab_resp_body">
                                    <table id="table_resp_body" data-msg-type="resp" class="table table-bordered table-hover">
                                        <thead>
                                        <tr>
                                            <th data-field="paramEname" data-formatter="fieldShowFormatter">参数英文名(key)</th>
                                            <th data-field="paramCname" data-formatter="fieldShowFormatter">参数中文名(name)</th>
                                            <th data-field="defValue" data-formatter="fieldShowFormatter">参数默认值(value)</th>
                                            <th data-field="ifUse" data-formatter="ifFormatter">是否解析/是否rowkey</th>
                                            <th data-field="infoId" data-formatter="optFormatter">操作</th>
                                        </tr>
                                        </thead>
                                        <tbody class="box-min-table"> </tbody>
                                    </table>
                                </div>
                            </div>
                        </div>

                    </div>
                    <!------- 列表 end -------->
                </div>
            </div>

            <div win-title="修改窗口" class="modal fade" id="my_modal_edit" tabindex="-1" role="dialog"
                 aria-labelledby="myModalLabel" aria-hidden="true">
                <div class="modal-dialog" style="width:60%;">
                    <div class="modal-content">
                        <div class="modal-header">
                            <button type="button" class="close" data-dismiss="modal" aria-hidden="true">
                                ×
                            </button>
                            <h4 class="modal-title">
                                <font color="red">参数高级配置</font> 
                            </h4>
                        </div>
                        <div class="modal-body">
                            <div class="nav-tabs-custom">
                                <ul class="nav nav-tabs" id="myTab-edit">
                                </ul>

                                <!-- tab content start -->
                                <div class="tab-content">

                                    <div class="tab-pane active" id="tabEdit_1">
                                        <form class="form-horizontal editFormBody" role="form" id="editForm1"
                                              action="javascript:void(0)">
                                            <input type="hidden" class="formToken" id="editForm1_formToken"
                                                   name="formToken"/>
                                            <!-- temp="editForm1_hidden" start -->
                                            <div id="editForm1_hidden">
                                                <input type="hidden" name="pageName" value="dx-msg-format-set"/>
                                                <input type="hidden" name="formName" value="editForm"/>
                                                <input type="hidden" name="dxMsgFormatSet.w_infoId" data-name="dxMsgFormatSet.infoId" class="clean"/>
                                            </div>
                                            <!-- temp="editForm1_hidden" end -->

                                            <!-- temp="editForm1_content" start -->
                                            <div id="editForm1_content">


                                                <table class="table table-bordered bordercolor">
                                                    <tbody>
                                                    <tr>
                                                        <td class="w180" align="right"><label
                                                                class="form-control-static">参数英文名：</label></td>
                                                        <td>
                                                            <div class="form-group"><input
                                                                    name="dxMsgFormatSet.paramEname"
                                                                    class="form-control clean" maxlength="100"
                                                                    data-name="dxMsgFormatSet.paramEname"
                                                                    onblur="mytools.validFieldRepeat(this)"
                                                                    data-validate-repeat-message="参数英文名已存在，请更换！"
                                                                    data-validate-repeat-selfname="dxMsgFormatSet.w_infoId"
                                                                    placeholder="必填项，只能由字母、数字、下划线组成" data-bv-notempty="true" data-bv-notempty-message="不能为空"
                                                                    data-bv-regexp="true" data-bv-regexp-regexp="^[A-Za-z0-9_-]*$" data-bv-regexp-message="只能由字母、数字、下划线组成"></div>
                                                        </td>
                                                    </tr>
                                                    <tr>
                                                        <td align="right"><label
                                                                class="form-control-static">参数中文名：</label></td>
                                                        <td>
                                                            <div class="form-group"><input
                                                                    name="dxMsgFormatSet.paramCname"
                                                                    class="form-control clean" maxlength="50"
                                                                    data-temp-obj="dxMsgFormatSet.paramCname"
                                                                    placeholder="必填项" data-bv-notempty="true"
                                                                    data-bv-notempty-message="不能为空"
                                                                    data-name="dxMsgFormatSet.paramCname"></div>
                                                        </td>
                                                    </tr>
                                                    <tr>
                                                        <td align="right"><label
                                                                class="form-control-static">参数类型：</label></td>
                                                        <td>
                                                            <div class="form-group"><select
                                                                    id="editForm1_dxMsgFormatSet_paramType"
                                                                    name="dxMsgFormatSet.paramType"
                                                                    class="form-control  clean"
                                                                    data-temp-obj="dxMsgFormatSet.paramType"
                                                                    data-dict-code="dictItemList"
                                                                    data-dict-cate="paramType" data-type-tag="select"
                                                                    data-def="" data-name="dxMsgFormatSet.paramType"
                                                                    placeholder="必填项" data-bv-notempty="true"
                                                                    data-bv-notempty-message="不能为空">
                                                                <option value="">--请选择--</option>
                                                            </select></div>
                                                        </td>
                                                    </tr>
                                                    <tr>
                                                        <td align="right"><label
                                                                class="form-control-static">参数默认值：</label></td>
                                                        <td>
                                                            <div class="form-group"><input
                                                                    name="dxMsgFormatSet.s_defValue"
                                                                    class="form-control clean" maxlength="50"
                                                                    data-temp-obj="dxMsgFormatSet.defValue"
                                                                    data-name="dxMsgFormatSet.defValue"
                                                                    placeholder="非必填"></div>
                                                        </td>
                                                    </tr>
                                                    <tr>
                                                        <td align="right"><label
                                                                class="form-control-static">参数映射字段英文名：</label></td>
                                                        <td>
                                                            <div class="form-group"><input
                                                                    name="dxMsgFormatSet.cloumEname"
                                                                    class="form-control clean" maxlength="100"
                                                                    data-temp-obj="dxMsgFormatSet.cloumEname"
                                                                    data-name="dxMsgFormatSet.cloumEname"
                                                                    onblur="mytools.validFieldRepeat(this)"
                                                                    data-validate-repeat-message="参数映射字段英文名已存在，请更换！"
                                                                    data-validate-repeat-selfname="dxMsgFormatSet.w_infoId"
                                                                    placeholder="必填项，只能由字母、数字、下划线组成" data-bv-notempty="true" data-bv-notempty-message="不能为空"
                                                                    data-bv-regexp="true" data-bv-regexp-regexp="^[A-Za-z0-9_-]*$" data-bv-regexp-message="只能由字母、数字、下划线组成"></div>
                                                        </td>
                                                    </tr>
                                                    <tr>
                                                        <td align="right"><label
                                                                class="form-control-static">是否允许为空：</label></td>
                                                        <td>
                                                            <div class="form-group">
                                                                <div class="form-control-static"
                                                                     id="editForm1_dxMsgFormatSet_ifNull"
                                                                     name="dxMsgFormatSet.ifNull"
                                                                     data-temp-obj="dxMsgFormatSet.ifNull"
                                                                     data-dict-code="dictItemList"
                                                                     data-dict-cate="enabled" data-colmun=""
                                                                     data-condition="" data-type-tag="radio" data-def="1"
                                                                     data-name="dxMsgFormatSet.ifNull">[radio]
                                                                </div>
                                                            </div>
                                                        </td>
                                                    </tr>
                                                    <tr>
                                                        <td align="right"><label
                                                                class="form-control-static">是否解析：</label></td>
                                                        <td>
                                                            <div class="form-group">
                                                                <div class="form-control-static"
                                                                     id="editForm1_dxMsgFormatSet_ifUse"
                                                                     name="dxMsgFormatSet.ifUse"
                                                                     data-temp-obj="dxMsgFormatSet.ifUse"
                                                                     data-dict-code="dictItemList"
                                                                     data-dict-cate="enabled" data-colmun=""
                                                                     data-condition="" data-type-tag="radio" data-def="0"
                                                                     data-name="dxMsgFormatSet.ifUse">[radio]
                                                                </div>
                                                            </div>
                                                        </td>
                                                    </tr>
                                                    <tr>
                                                        <td align="right"><label
                                                                class="form-control-static">是否参与rowkey设计：</label></td>
                                                        <td>
                                                            <div class="form-group">
                                                                <div class="form-control-static"
                                                                     id="editForm1_dxMsgFormatSet_ifRowKey"
                                                                     name="dxMsgFormatSet.ifRowKey"
                                                                     data-temp-obj="dxMsgFormatSet.ifRowKey"
                                                                     data-dict-code="dictItemList"
                                                                     data-dict-cate="enabled" data-colmun=""
                                                                     data-condition="" data-type-tag="radio" data-def="0"
                                                                     data-name="dxMsgFormatSet.ifRowKey">[radio]
                                                                </div>
                                                            </div>
                                                        </td>
                                                    </tr>

                                                    </tbody>
                                                </table>

                                            </div>
                                            <!-- temp="editForm1_content" end -->

                                            <div class="form-group">
                                                <div class="col-sm-12">
                                                    <div class="box-footer text-center">
                                                        <button class="btn btn-success pull-left" type="button"
                                                                onclick="mytools.closeModal('my_modal_edit');"> 取消
                                                        </button>
                                                        <button class="btn btn-danger pull-right" type="button"
                                                                onclick="submitForm1('editForm1','');"
                                                                data-temp-event="editForm1_hidden"> 提 交
                                                        </button>
                                                    </div>
                                                </div>
                                            </div>
                                        </form>
                                    </div>

                                </div>
                                <!-- tab content e -->
                            </div>
                        </div>
                    </div>
                    <!-- /.modal-content -->
                </div>
            </div>


            <div win-title="查看报文格式窗口" class="modal fade" id="my_modal_msg_format_view" tabindex="-2" role="dialog"
                 aria-labelledby="myModalLabel" aria-hidden="true">
                <div class="modal-dialog" style="width:80%;">
                    <div class="modal-content">
                        <div class="modal-header">
                            <button type="button" class="close" data-dismiss="modal" aria-hidden="true">
                                ×
                            </button>
                            <h4 class="modal-title">
                                <font color="red">报文格式</font>
                                <a class="f12" href="javascript:;" onclick="copyMsg()">复制报文</a>
                            </h4>
                        </div>
                        <div class="modal-body viewForm">
                            <textarea rows="2" id="copy_textarea" style="display: none" cols="100"></textarea>
                            <div class="panel">
                                <pre style="min-height:360px; overflow-y: scroll;"><code id="viewForm1_msg_form_json"></code></pre>
                            </div>
                        </div>
                    </div>
                    <!-- /.modal-content -->
                </div>
            </div>

            <div win-title="导入报文格式窗口" class="modal fade" id="my_modal_msg_format_import" tabindex="-2" role="dialog"
                 aria-labelledby="myModalLabel" aria-hidden="true">
                <div class="modal-dialog" style="width:80%;">
                    <div class="modal-content">
                        <div class="modal-header">
                            <button type="button" class="close" data-dismiss="modal" aria-hidden="true">
                                ×
                            </button>
                            <h4 class="modal-title">
                                <font color="red">快速导入报文[<span id="span_rmft_code"></span>]</font>
                            </h4>
                        </div>
                        <div class="modal-body viewForm">
                            <div class="panel-body">
                                <form id="importMsgForm" action="javascript:;">
                                    <div class="hidden">
                                        <input name="tableId" value=""/>
                                        <input name="pageName" value="dx-msg-format-set-addbatch"/>
                                        <input name="formName" value="addFormBatch"/>
                                        <input name="ifBatch" value="T"/>
                                        <input name="dxMsgFormatSet.splitAttr" value="interfaceId"/>
                                        <input name="interfaceId" class="param_interfaceId" value=""/>
                                        <input name="interfaceRMFT" class="param_interfaceRMFT" value=""/>
                                        <input name="interfaceCode" class="param_interfaceCode" value=""/>
                                        <input name="paramType" value="2"/>
                                        <input name="ifNull" value="1"/>
                                        <input name="msgType" value=""/>
                                        <input name="paramParent" value=""/>
                                    </div>
                                    <textarea name="dataStr" rows="20" id="textarea_msg_import" style="width: 100%;height: 100%;border:1px #ccc solid;" placeholder=""></textarea>
                                </form>
                                <div class="pull-right pt5"><button class="btn btn-primary" onclick="saveImportMsgFormat('importMsgForm')">提交保存</button></div>
                            </div>
                        </div>
                    </div>
                    <!-- /.modal-content -->
                </div>
            </div>

            <!-- Part 二、以下是template模板定义的模块区域 -->

            <!-- Part 三、 以下是js模块区域 -->
            <script>
                var clickMenu = "msg-format-list";
                var myPage = 10;//定义列表数据
                dataListId = "dataList";//显示列表数据div的id
                var searchFormId = "searchForm";//搜索表单Id
                var selected_tab_nums=3;//控制默认选中状态的tab标签序号

                var selected_interfaceId='<c:out value="${param.interfaceId}"/>';
                    selected_interfaceCode='<c:out value="${param.interfaceCode}"/>',
                    selected_interfaceRMFT='<c:out value="${param.interfaceRMFT}"/>',
                    selected_requestWay='<c:out value="${param.requestWay}"/>',
                    selected_interfaceName='<c:out value="${param.interfaceName}"/>',
                    backUrl='<c:out value="${param.backUrl}"/>';
                var selected_id, selected_paramEname,selected_ifSubParam,selected_parentId,selected_tableId;
                var levelType="";
                var selected_nodes=[];
                /**
                 * 初始化数据字典，id传入#id 返回值Map用法：dictListMap["userType"][rows[i].userType]
                 */
                var dictListMap = DictUtil.initDictAndDymic();
                var $tableReqParams=$("#table_req_params"), $tableReqHeader=$('#table_req_header'),
                    $tableReqBody=$('#table_req_body'),$tableResBody=$('#table_resp_body');
                function initParamsData(){
                    $(".param_interfaceId").val(selected_interfaceId).text(selected_interfaceId);
                    $(".param_interfaceCode").val(selected_interfaceCode).text(selected_interfaceCode);
                    $(".param_interfaceName").val(selected_interfaceName).text(selected_interfaceName);
                    $(".param_interfaceRMFT").val(selected_interfaceRMFT).text(selected_interfaceRMFT);
                    $(".param_requestWay").val(selected_requestWay).text(selected_requestWay);

                    $('a[data-toggle="tab"]').eq(selected_tab_nums-1).click();//控制第几个标签选中-模拟点击一次
                }
                $(function () {
                    initParamsData();
                    //1、加载分页列表数据
                    getTableDataAll();
                    //2、控制是否启用token
                    //setToken();

                });

                //控制选项卡
                $('a[data-toggle="tab"]').on('shown.bs.tab', function (e) {
                    var lastTabId =  $(e.relatedTarget).attr("href");   // 上一次活动的标签页
                    var currTabId = $(e.target).attr("href");// 当前活动的标签页
                    console.log('clicked.shown.tab->',lastTabId,currTabId);
                });

                function getTableDataAll() {
                    getTableData($tableReqParams);
                    getTableData($tableReqHeader);
                    getTableData($tableReqBody);
                    getTableData($tableResBody);
                }

                //给模态窗口内form表单内的所有支持必填项的元素注入校验
                $(".modal").on('shown.bs.modal', function () {
                    $(this).find("form").each(function () {
                        var formId = $(this).attr("id");
                        if (!strUtil.isNull(formId)) {
                            formId = "#" + formId;
                            setValidate(formId);//定义add表单验证属性
                            mytools.cleanValidate(formId);//清空上次校验规则提示
                        }
                    });
                });

                //加载列表数据
                function getTableData($table) {
                    var index_load = layer.load(1, {shade: false});
                    var tableId=$table.attr("id"),msgType=$table.attr("data-msg-type");
                    $("#"+searchFormId).find("input[name='dxMsgFormatSet.w_msgType']").val(msgType);
                    $table.bootstrapTable('destroy');
                    $table.bootstrapTable({
                        url: common_list_url + '?' + $('#'+searchFormId).serialize(),
                        idField: 'infoId',
                        uniqueId:'infoId',
                        treeShowField: 'paramEname',//在哪一列展开树形
                        parentIdField: 'paramParent',//指定父id列
                        formatNoMatches:function(){
                            var noHtml = "暂无数据，";
                            if('header'==msgType||'params'==msgType){
                                noHtml+="请增加子节点";
                            }else{
                                noHtml+="<a href='javascript:;' onclick=\"initDefRoot('"+tableId+"','"+msgType+"')\" class='red'>[点此]</a>快速初始化根节点";
                            }
                            return noHtml;
                        },
                        onClickRow: function (row, $element, field) {
                            $element.addClass('selected').siblings().removeClass('selected');
                            selection(row, $element, field);
                        },
                        onDblClickRow:function(row, $element, field){
                            console.log('onDblClickRow',row, $element, field);
                            var infoId = row.infoId;
                            var isEdit = false;
                            if($element.find(".swt-input").is(".hidden")){
                                isEdit = true;
                            }
                            if(isEdit){
                                $element.find(".swt-span").addClass("hidden");
                                $element.find(".swt-input").removeClass("hidden");
                                $element.find(".swt-input").each(function () {
                                    $(this).val($(this).parent().find(".swt-span").text());
                                });

                                $element.find(".swt-btn-save").removeClass("hidden");
                                $element.find(".swt-btn-add").addClass("hidden");
                                $element.find(".swt-btn-del").addClass("hidden");
                            }else{
                                $element.find(".swt-span").removeClass("hidden");
                                $element.find(".swt-input").addClass("hidden");

                                $element.find(".swt-btn-save").addClass("hidden");
                                $element.find(".swt-btn-add").removeClass("hidden");
                                $element.find(".swt-btn-del").removeClass("hidden");
                            }
                        },
                        onLoadSuccess: function (data) {//加载成功时执行
                            var allTableData = $table.bootstrapTable('getData');
                            console.log('getTableData['+tableId+']['+msgType+']',allTableData);
                            if(allTableData.length>0){
                                $table.treegrid({
                                    initialState: 'expanded',// collapsed=所有节点都折叠，'expanded'=所有节点都展开，默认展开
                                    // treeColumn: 1,
                                    expanderExpandedClass: 'fa fa-caret-down',  //图标样式
                                    expanderCollapsedClass: 'fa fa-caret-right',
                                    onChange: function () {
                                        $table.bootstrapTable('resetWidth');
                                    }
                                });
                            }
                            layer.close(index_load);
                        }
                    });
                }

                //初始化根节点
                function initDefRoot(tableId,msgType){
                    selected_tableId = tableId;
                    var $table = $('#'+tableId);
                    var paramData = {};
                    paramData["dxMsgFormatSet.paramParent"] = '0';
                    paramData["dxMsgFormatSet.ifNull"] = '1';
                    paramData["dxMsgFormatSet.ifSubParam"] = '0';
                    paramData["dxMsgFormatSet.interfaceId"] = selected_interfaceId;
                    paramData["dxMsgFormatSet.interfaceCode"] = selected_interfaceCode;
                    paramData["dxMsgFormatSet.interfaceRMFT"] = selected_interfaceRMFT;
                    paramData["dxMsgFormatSet.msgType"] = msgType;
                    paramData["dxMsgFormatSet.cloumEname"] = 'defaultRoot';
                    paramData["dxMsgFormatSet.paramCname"] = '默认根节点';
                    paramData["dxMsgFormatSet.paramEname"] = 'defaultRoot';
                    paramData["dxMsgFormatSet.paramType"] = '2';
                    paramData["dxMsgFormatSet.ifUse"] = '0';
                    paramData["dxMsgFormatSet.ifRowKey"] = '0';

                    saveDxMsgFormatSetData($table,paramData,'add',"");
                }
                //保存(新增，修改）和删除数据
                function saveDxMsgFormatSetData($table,paramData,types,infoId) {
                    paramData["pageName"] = "dx-msg-format-set";
                    if(types=='add'){
                        paramData["formName"] = "addForm";
                        paramData["dxMsgFormatSet.ifUse"] = "0";
                        paramData["dxMsgFormatSet.ifRowKey"] = "0";
                    }else if (types=='del'){
                        paramData["formName"] = "delForm";
                        paramData["dxMsgFormatSet.w_infoId"] = infoId;
                    }else if (types=='delAll'){
                        paramData["formName"] = "delForm";
                        paramData["dxMsgFormatSet.w_interfaceId"] = selected_interfaceId;
                        paramData["dxMsgFormatSet.w_msgType"]=$table.attr("data-msg-type");
                    }else if (types=='edit'){
                        paramData["formName"] = "editForm";
                        paramData["dxMsgFormatSet.w_infoId"] = infoId;
                    }
                    console.log('saveDxMsgFormatSetData['+types+']req',paramData);
                    $.ajax({
                        type: "post",url: common_submit_url,data: paramData, dataType: "json",
                        success: function (myData) {
                            console.log('saveDxMsgFormatSetData['+types+']res',myData);
                            var result = myData.flag;
                            if (result == "T") {
                                // layer.msg("操作完成！");
                                $table.bootstrapTable('refresh');
                                if (types=='del'){
                                    //判断当前节点的父节点旗下已无其他子节点
                                    var rowData = $table.bootstrapTable('getRowByUniqueId',infoId);//根据唯一标识id获取当前行的data
                                    if(rowData){
                                        var fatherId = rowData._parent.infoId;
                                        var fatherChildNodesLen = rowData._parent._nodes.length;
                                        if(fatherChildNodesLen==1){
                                            updateIfSubParam(fatherId,'0');
                                        }
                                    }
                                }
                            } else {
                                layer.msg("操作失败！");
                            }
                        }
                    });
                }
                //字段格式化显示
                function fieldShowFormatter(value, row, index,fieldName) {
                    // console.log(index,value,row,fieldName);
                    var brothersLength="";
                    var childLength=row._nodes.length;
                    var parentId="";
                    var seeMsgFormat="";
                    var infoId = row.infoId;
                    var optHtml = "";
                    var msgType = row.msgType;
                    var isShowDel = false;
                    if('header'==msgType||'params'==msgType){
                        isShowDel = true;
                    }else{
                        if(row._parent) {//非顶级
                            isShowDel = true;
                            brothersLength = row._parent._nodes.length;
                            parentId = row._parent.infoId;
                        }else{
                            //非顶级
                            optHtml=strUtil.doNull(value,"");
                        }
                    }
                    if (isShowDel){
                        var valueData = strUtil.doNull(value,"");
                        var showText = strUtil.doNull(valueData,"");
                        var input_id = "input_"+infoId+"_"+fieldName;
                        if(row['controlType']=='add'){//页面临时新增的数据（未入库保存）
                            var addInputObj = $("<input id='"+input_id+"' name='"+fieldName+"' data-info-id='"+infoId+"' maxlength='90' value='"+valueData+"'/>");
                            optHtml = addInputObj.prop("outerHTML");
                        }else{
                            var labelObj = $("<label class='swt-box'></label>");
                            var addSpanObj = $("<span class='swt-span'>"+showText+"</span>");
                            var addInputObj = $("<input id='"+input_id+"' class='swt-input hidden' name='"+fieldName+"' data-info-id='"+infoId+"' value='"+valueData+"'/>");
                            labelObj.append(addSpanObj).append(addInputObj);
                            optHtml = labelObj.prop("outerHTML");
                        }
                    }
                    return optHtml;
                }
                function ifFormatter(value, row) {
                    var ifUseText = "否";
                    var ifRowKeyText = "否";
                    var ifUse = row.ifUse;
                    var ifRowKey = row.ifRowKey;
                    if("1"==ifUse){
                        ifUseText="是";
                    }
                    if("1"==ifRowKey){
                        ifRowKeyText="是";
                    }
                    return ifUseText+"/"+ifRowKeyText;
                }

                /**
                //span元素切换input
                function switchSpanToInput(ob,type) {
                    var obj = $(ob);
                    var fieldName = obj.attr("field-name");
                    var fieldData = obj.attr("field-data");
                    var fieldId = obj.attr("field-id");
                    var input_id = fieldId+"_"+new Date().getTime();
                    var addInputObj = $("<input id='"+input_id+"' name='"+fieldName+"' field-name='"+fieldName+"' field-data='"+fieldData+"' field-id='"+fieldId+"' value='"+fieldData+"'/>");
                    addInputObj.on({
                        "mouseout":function () {//鼠标移开
                            switchInputToSpan($(this));
                        },
                        "blur":function () {//光标移开
                            switchInputToSpan($(this));
                        }
                    });
                    obj.after(addInputObj).remove();
                }
                //input元素切换span
                function switchInputToSpan(obj) {
                    var fieldName = obj.attr("field-name");
                    var fieldId = obj.attr("field-id");
                    var tableId = obj.parents("table").attr("id");
                    var $table = $('#'+tableId),msgType=$table.attr("data-msg-type");
                    var newValue=obj.val(); //获取改变后的输入框的值
                    var oldvalue = obj.attr("field-data"); //获取输入框原本的值
                    if(!strUtil.isNull(newValue)&&'paramEname'==fieldName){
                        var regs = /^[A-Za-z0-9_-]*$/;
                        if(!regs.test(newValue)){//不符合规则则使用原值
                            layer.tips('输入的格式不合法', '#'+obj.attr("id"), {tips: 3});
                            newValue = oldvalue
                        }
                    }
                    console.log(tableId+'.['+fieldId+'|'+fieldName+']->',"old["+oldvalue+"]","new["+newValue+"]");
                    if(oldvalue!=newValue){
                        var paramData = {};
                        var isSave = true;
                        if('defValue'==fieldName){
                            paramData["dxMsgFormatSet.s_"+fieldName]=newValue;
                        }else{
                            if(!strUtil.isNull(newValue)){
                                paramData["dxMsgFormatSet."+fieldName]=newValue;
                            }else{
                                isSave = false;
                                newValue=oldvalue;
                            }
                        }
                        if(isSave){
                            console.log('调用后台保存修改...');
                            //调用后台保存
                            saveDxMsgFormatSetData($table,paramData,'edit',fieldId);
                        }
                    }
                    var showText = strUtil.doNull(newValue,"-");
                    var addSpanObj = $("<span field-name='"+fieldName+"' field-data='"+newValue+"' field-id='"+fieldId+"' ondblclick=\"switchSpanToInput(this,1)\">"+showText+"</span>");
                    obj.after(addSpanObj).remove();
                }**/
                //操作列格式转换
                function optFormatter(value, row, index){
                    var infoId = row.infoId;
                    var childLength=row._nodes.length;
                    var msgType = row.msgType;
                    var isShowDel = false;
                    var optHtml = "";
                    if('header'==msgType||'params'==msgType){
                        isShowDel = true;
                    }else{
                        if(row._parent) {//非顶级
                            isShowDel = true;
                        }else{
                            optHtml += "<button type=\"button\" data-info-id=\""+infoId+"\" class=\"btn btn-default btn-xs swt-btn-add\" title='增加子节点' onclick=\"addNodeRows(this)\"><i class=\"fa fa-plus-circle\"></i></button>";
                            if('xml'==selected_interfaceRMFT){
                                optHtml += "<button type=\"button\" data-info-id=\""+infoId+"\" class=\"btn btn-default btn-xs "+hid_set+"\" title='高级配置' onclick=\"openNodeSet(this)\"><i class=\"fa fa-cog\"></i></button>";
                            }
                            optHtml += "<button type=\"button\" data-info-id=\""+infoId+"\" class=\"btn btn-default btn-xs\" onclick=\"toSeeMsgFormat(this,"+childLength+")\"><i class=\"fa fa-search-plus\"></i> 查看报文</button>";
                            optHtml += "<button type=\"button\" data-info-id=\""+infoId+"\" class=\"btn btn-default btn-xs\" onclick=\"openImportMsgFormat(this)\"><i class=\"fa fa-upload\"></i> 快速导入</button>";
                            optHtml += "<button type=\"button\" data-info-id=\""+infoId+"\" class=\"btn btn-default btn-xs\" onclick=\"delNodeRows(this,'all')\"><i class=\"fa fa-trash\"></i> 全部删除</button>";
                        }
                    }
                    if(isShowDel){
                        var hid_save=" hidden",hid_add="",hid_set="",btn_disab="";
                        if(row['controlType']){//标识是临时细节点
                            hid_save="";
                            hid_add=" hidden";
                            hid_set=" hidden";
                            // btn_disab="disabled='disabled'";//删除按钮禁用
                        }
                        optHtml += "<button type=\"button\" data-info-id=\""+infoId+"\" class=\"btn btn-success btn-xs swt-btn-save "+hid_save+"\" title='保存数据' onclick=\"saveNodeRows(this)\"><i class=\"fa fa-save\"></i></button>";
                        if(row._parent) {//非顶级
                            optHtml += "<button type=\"button\" data-info-id=\""+infoId+"\" class=\"btn btn-default btn-xs swt-btn-add "+hid_add+"\" title='增加子节点' onclick=\"addNodeRows(this)\"><i class=\"fa fa-plus-circle\"></i></button>";
                        }
                        optHtml += "<button type=\"button\" data-info-id=\""+infoId+"\" class=\"btn btn-default btn-xs "+hid_set+"\" title='高级配置' onclick=\"openNodeSet(this)\"><i class=\"fa fa-cog\"></i></button>";
                        if(childLength>0){
                            btn_disab="disabled='disabled'";//删除按钮禁用
                        }
                        optHtml += "<button type=\"button\" "+btn_disab+" data-info-id=\""+infoId+"\" class=\"btn btn-default btn-xs swt-btn-del\" title='删除节点' onclick=\"delNodeRows(this,'self')\"><i class=\"fa fa-trash-o\"></i></button>";
                    }
                   return optHtml;
                }
                //给当前节点追加子节点
                function addNodeRows(ob){
                    var obj = $(ob);
                    var fatherId = obj.attr("data-info-id");
                    var tableId = obj.parents("table").attr("id");
                    var $table = $('#'+tableId),msgType=$table.attr("data-msg-type");
                    var count = $table.bootstrapTable('getData').length;
                    var infoIdVal = 'pk'+new Date().getTime()+parseInt(((Math.random() * 9 + 1) * 1000));//pk+时间戳+4位随机数
                    var addData = {"controlType":"add",
                        "infoId":infoIdVal,"msgType":msgType,"ifSubParam":"0","ifNull":"1","paramType":"2",
                        "paramEname":"","paramCname":"","cloumEname":"","defValue":"","paramParent":fatherId,
                        "interfaceRMFT":selected_interfaceRMFT,"interfaceId":selected_interfaceId,"interfaceCode":selected_interfaceCode};
                    $table.bootstrapTable('insertRow',{index:count,row: addData});
                    $table.treegrid({
                        initialState: 'expanded',
                        expanderExpandedClass: 'fa fa-caret-down',  //图标样式
                        expanderCollapsedClass: 'fa fa-caret-right',
                        onChange: function () {
                            $table.bootstrapTable('resetWidth');
                        }
                    });
                }
                //保存当前节点行的信息
                function saveNodeRows(ob) {
                    var obj = $(ob);
                    var trObj = obj.parents("tr");
                    var infoId = obj.attr("data-info-id");
                    var tableId = obj.parents("table").attr("id");
                    var $table = $('#'+tableId),msgType=$table.attr("data-msg-type");
                    var rowData = $table.bootstrapTable('getRowByUniqueId',infoId);//根据唯一标识id获取当前行的data
                   if(rowData){
                       console.log('saveNodeRows.rowData',rowData);
                       var inputData = {};
                       var isNext = true;
                       trObj.find("input").each(function () {
                           var inputName = $(this).attr("name");
                           var inputVal = $(this).val();
                           if('paramEname'==inputName){
                               if(strUtil.isNull(inputVal)){
                                   layer.tips('参数英文名不能为空', '#'+$(this).attr("id"), {tips: 3});
                                   isNext = false;
                                   return;
                               }
                               var regs = /^[A-Za-z0-9_.-]*$/;
                               if(!regs.test(inputVal)){//不符合规则则使用原值
                                   layer.tips('输入的格式不合法', '#'+$(this).attr("id"), {tips: 3});
                                   $(this).val('');
                                   isNext = false;
                                   return;
                               }
                           }
                           if('paramCname'==inputName){
                               if(strUtil.isNull(inputVal)){
                                   layer.tips('参数中文名不能为空', '#'+$(this).attr("id"), {tips: 3});
                                   isNext = false;
                                   return;
                               }
                           }
                           rowData[inputName]=inputVal;
                           inputData[inputName] = inputVal;
                       });
                       console.log('saveNodeRows.inputData',inputData);
                       if(!isNext)return;
                       var paramEnameVal = rowData.paramEname;
                       var paramData = {};
                       rowData["cloumEname"]=paramEnameVal;//映射字段值默认等价于参数英文名
                       if(rowData['controlType']){//首次新增，补充其他默认参数
                           for (var key in rowData){
                               if(key!='_level'&&key!='_parent'&&key!='_last'&&key!='_nodes'){
                                   paramData["dxMsgFormatSet."+key]=rowData[key];
                               }
                           }
                           //1、调用后台保存本节点
                           saveDxMsgFormatSetData($table,paramData,'add',"");
                       }else{//修改保存
                           for (var key in inputData){
                               if('defValue'==key){
                                   paramData["dxMsgFormatSet.s_"+key]=inputData[key];//默认值可以置空
                               }else{
                                   paramData["dxMsgFormatSet."+key]=inputData[key];
                               }
                           }
                           //1、调用后台保存本节点
                           saveDxMsgFormatSetData($table,paramData,'edit',infoId);
                       }

                       //2、判断是否更新父节点ifSubParam字段值
                       if(rowData._parent){
                           var fatherId = rowData._parent.infoId;
                           var ifSubParam = rowData._parent.ifSubParam;//获取父级【是否有下级】字段是否已标记了1
                           if(!strUtil.isNull(fatherId) && !strUtil.isNull(ifSubParam) && ifSubParam*1!=1){
                               updateIfSubParam(fatherId,'1');
                           }
                       }
                   }
                }
                //删除当前节点
                function delNodeRows(ob,flags) {
                    var obj = $(ob);
                    var infoId = obj.attr("data-info-id");
                    var tableId = obj.parents("table").attr("id");
                    var $table = $('#'+tableId),msgType=$table.attr("data-msg-type");
                    if(flags=='all'){
                        //删除全部
                        var index_submit = layer.confirm('全部删除后不可恢复，您确定要继续吗？', {btn: ['Yes', 'No'], closeBtn: 0, offset: '220px'}
                        , function () {
                            layer.close(index_submit);
                            saveDxMsgFormatSetData($table,{},'delAll','');
                        });
                    }else{
                        //删除当前
                        var rowData = $table.bootstrapTable('getRowByUniqueId',infoId);//根据唯一标识id获取当前行的data
                        if(rowData['controlType']){
                            //表示未入库保存过，则直接页面删除
                            obj.parent().parent().remove();
                            $table.bootstrapTable('removeByUniqueId',infoId);//根据唯一Id删除数据的方法
                            $table.bootstrapTable('refresh');
                            console.log('delNodeRows.removeByUniqueId',infoId);
                        }else{
                            console.log('delNodeRows.delById',infoId);
                            //调用后台保存
                            saveDxMsgFormatSetData($table,{},'del',infoId);
                        }
                    }
                }
                //弹出高级设置框
                function openNodeSet(ob) {
                    var obj = $(ob);
                    var index_load = layer.load(1, {shade: false});
                    var infoId = obj.attr("data-info-id");
                    var tableId = obj.parents("table").attr("id");
                    selected_tableId = tableId;
                    var $table = $('#'+tableId),msgType=$table.attr("data-msg-type");
                    mytools.cleanData(".editFormBody");//清空表单元素上次填写的内容；
                    $("#my_modal_edit").modal("show");
                    var paramLoadData = {};
                    paramLoadData["pageName"] = 'dx-msg-format-set';
                    paramLoadData["formName"] =  'searchForm';
                    paramLoadData["dxMsgFormatSet.w_infoId"] = infoId;
                    $.get(common_info_url, paramLoadData, function (myData) {
                        console.log("openNodeSet.view",myData);
                        //反显加载数据
                        if (myData) {
                            var myDataNew = {dxMsgFormatSet:myData};
                            for (var objNameKey in myDataNew) {
                                // console.log(objNameKey,myDataNew);
                                FormUtil.loadView(objNameKey, myDataNew[objNameKey], "#my_modal_edit");
                            }
                        }
                        layer.close(index_load);
                    }, "json");
                }

                //选中效果
                function selection(row, $element, field) {
                    console.log("selection.row",row,$element,field);
                    selected_id = row.infoId;
                    selected_paramEname = row.paramEname;
                    selected_interfaceId = row.interfaceId;
                    selected_interfaceCode = row.interfaceCode;
                    selected_ifSubParam = row.ifSubParam;
                    selected_interfaceRMFT = row.interfaceRMFT;
                    selected_nodes=row._nodes;
                }


                //提交tab1表单数据
                function submitForm1(formId, tabId) {
                    //校验规则-表单提交时触发
                    var validate = $('#' + formId).data('bootstrapValidator').validate();
                    if (!validate.isValid()) { //如果校验不通过就返回
                        return;
                    }
                    // if("json"==selected_interfaceRMFT){
                    //     var paramEnames="";
                    //     if(selected_nodes.length>0&&levelType=="child"){
                    //         for(var i = 0;i<selected_nodes.length;i++){
                    //             paramEnames += selected_nodes[i].paramEname;
                    //         }
                    //         if(paramEnames){
                    //             var paramEname = $("#addForm1").find("input[name='dxMsgFormatSet.paramEname']").val();
                    //             if(paramEnames.indexOf(paramEname)>-1){
                    //                 layer.alert("此参数英文名已经存在");
                    //                 return;
                    //             }
                    //         }
                    //     }
                    // }
                    var index_submit = layer.confirm('您确定要保存信息吗？', {btn: ['Yes', 'No'], closeBtn: 0, offset: '220px'}
                        , function () {
                            var result = submitForm(formId, tabId);
                            layer.close(index_submit);
                            if (result) {
                                // if(levelType=="child"&&"addForm1"==formId){
                                //     console.log("selected_ifSubParam",selected_ifSubParam);
                                //     if("T"!=selected_ifSubParam){
                                //         updateIfSubParam(selected_id,"1")
                                //     }
                                // }
                                layer.msg("保存高级配置成功！", {closeBtn: 0});
                                mytools.closeModal("my_modal_edit");
                                refresh();
                                setToken();
                            }
                        });

                }
                //同步更新父节点
                function updateIfSubParam(infoId,value) {
                    console.log('updateIfSubParam','同步更新父节点['+infoId+']，标记字段ifSubParam='+value);
                    $.ajax({
                        type: 'post',
                        url: common_submit_url,
                        data: {"pageName":"dx-msg-format-set","formName":"editForm",
                            "dxMsgFormatSet.w_infoId":infoId,"dxMsgFormatSet.ifSubParam":value},
                        dataType: 'json',
                        success: function (myData) {
                            console.log('updateIfSubParam',myData);
                        },
                        error: function (e) {
                        }
                    });
                }

                //提交表单数据
                function submitForm(formId, tabId) {
                    var result;
                    var index_load = layer.load(1, {shade: false});
                    $.ajax({
                        type: 'post',
                        url: common_submit_url,
                        data: $("#" + formId).serialize(),
                        async: false,
                        dataType: 'json',
                        success: function (myData) {
                            console.log(myData);
                            if (myData.flag == "T") {
                                result = myData;
                            } else {
                                setToken();
                                layer.msg(myData.msg);
                            }
                            layer.close(index_load);
                        },
                        error: function (e) {
                            layer.close(index_load);
                        }
                    });
                    return result;
                }
                /**
                function setdataShortName(obj,formId) {
                    var val = $(obj).val();
                    $("#"+formId).find("input[name='dxMsgFormatSet.paramEname']").val(val);
                }

                function yesOrNoFormatter(value, row, index) {
                    var flag = "否";
                    if("T"==value||"1"==value){
                        flag = "是";
                    }
                    return flag;
                }
                function paramTypeFormatter(value, row, index) {
                    var test = "_";
                    if("1"==value){
                        test = "数字";
                    }else if("2"==value){
                        test = "字符串";
                    }
                    return test;
                }
**/
                //刷新
                function refresh() {
                    selected_id = "";
                    selected_paramEname = "";
                    selected_interfaceId = "";
                    selected_interfaceCode = "";
                    selected_ifSubParam = "";
                    selected_nodes=[];
                    var $table = $('#'+selected_tableId),msgType=$table.attr("data-msg-type");
                    getTableData($table);
                }

                function openImportMsgFormat(ob) {
                    var obj = $(ob);
                    var infoId = strUtil.doNull(obj.attr("data-info-id"),"0");
                    var tableId = obj.parents("table").attr("id");
                    var $table = $('#'+tableId),msgType=$table.attr("data-msg-type");
                    var bodyRowsLen = $table.find("tbody tr").length;
                    if(bodyRowsLen>1){
                        layer.msg("已存在报文结构，不能重复导入！");
                        return;
                    }
                    $("#importMsgForm").find("input[name='msgType']").val(msgType);
                    $("#importMsgForm").find("input[name='paramParent']").val(infoId);
                    $("#importMsgForm").find("input[name='tableId']").val(tableId);
                    $("#span_rmft_code").text(selected_interfaceRMFT);
                    $("#textarea_msg_import").attr("placeholder","请输入或者粘贴完整报文的内容，格式必须保证符合"+selected_interfaceRMFT+"要求！");
                    $("#textarea_msg_import").val("");
                    $("#my_modal_msg_format_import").modal("show");
                }
                function saveImportMsgFormat(formId) {
                    var tableId = $("#"+formId).find("input[name='tableId']").val();
                    var fatherId = $("#"+formId).find("input[name='paramParent']").val();
                    var $table = $('#'+tableId),msgType=$table.attr("data-msg-type");
                    var index_submit = layer.confirm('您确定要保存信息吗？', {btn: ['Yes', 'No'], closeBtn: 0, offset: '220px'}
                    , function () {
                            layer.close(index_submit);
                            var index_load = layer.msg("数据正在导入中...");
                            $.ajax({
                                type: 'post',
                                url: common_submit_url,
                                data: $("#" + formId).serialize(),
                                dataType: 'json',
                                success: function (myData) {
                                    console.log('importMsgFormat',myData);
                                    if(myData.flag=='T'){
                                        layer.msg("操作成功！");
                                        updateIfSubParam(fatherId,'1');
                                        mytools.closeModal("my_modal_msg_format_import");
                                        getTableData($table);
                                    }else{
                                        layer.msg(myData.msg);
                                    }
                                    layer.close(index_load);
                                },
                                error: function (e) {
                                    layer.close(index_load);
                                }
                            });
                    });
                }

                //查看报文格式
                function toSeeMsgFormat(ob,childLength) {
                    var obj = $(ob);
                    var tableId = obj.parents("table").attr("id");
                    var $table = $('#'+tableId),msgType=$table.attr("data-msg-type");
                    var flag= false;
                    if("json"==selected_interfaceRMFT){
                        if(childLength>0){
                            flag=true;
                        }else{
                            layer.msg("请增加子节点后,再查看报文");
                            return;
                        }
                    }else{
                        flag=true;
                    }
                    if(flag){
                        var paramLoadData={};
                        paramLoadData["pageName"] = "dx-msg-format-set-search";
                        paramLoadData["formName"] = "searchForm";
                        paramLoadData["interfaceId"] = selected_interfaceId;
                        paramLoadData["msgFormatType"] = selected_interfaceRMFT;
                        paramLoadData["msgType"] = msgType;
                        $.get(common_info_url, paramLoadData, function (myData) {
                            console.log("myData".myData);
                            if(myData.result=="T"){
                                // var htm = HTMLEncode(JSON.stringify(myData.entity));
                                // var htm = "<div><span style='color: black'>" + myData.msg+ "</span></div>";
                                // "<div><span>分类错误数据：</span><span style='color:red;'>" + errProCount + "</span></div>";
                                if("json"==selected_interfaceRMFT){
                                    mytools.showJsonViewer(myData.entity,"viewForm1_msg_form_json");
                                }else{
                                    mytools.showXmlFormat("viewForm1_msg_form_json",myData.entity);
                                }
                                $("#my_modal_msg_format_view").modal("show");
                            }else{
                                layer.msg(myData.entity);
                            }
                        }, "json");
                    }
                }
                function copyMsg() {
                    $('#copy_textarea').val($("#viewForm1_msg_form_json").text()).show();
                    var copy_textareaObj=document.getElementById("copy_textarea");
                    copy_textareaObj.select(); // 选择对象
                    document.execCommand('copy', false, null);
                    $('#copy_textarea').hide();
                    layer.msg("复制成功！");
                }
                function HTMLEncode(html) {
                    var temp = document.createElement("div");
                    // console.dir(temp);
                    (temp.textContent != null) ? (temp.textContent = html) : (temp.innerText = html);
                    var output = temp.innerHTML;
                    temp = null;
                    return output;
                }

                //设置token
                function setToken() {
                    $.ajax({
                        type: 'get',
                        url: '${ctx}/sendPage/token?token=true',
                        dataType: 'text',
                        success: function (myData) {
                            console.log(myData);
                            $('.formToken').val(myData);
                        }
                    });
                }
                function goBack() {
                    var url =page_admin+strUtil.doNull(backUrl,'/conf/msg-format-list');
                    mytools.pjax(url);
                }

                /**** Part 四、以下是自定义新增方法  ****/
                function setValidate(id) {
                    $(id).each(function () {
                        $(this).bootstrapValidator({
                            feedbackIcons: {
                                valid: 'glyphicon glyphicon-ok',
                                invalid: 'glyphicon glyphicon-remove',
                                validating: 'glyphicon glyphicon-refresh'
                            }, /** 以下需要结合实际业务清空补充个表单元素的验证规则 **/
                            fields: {
                                /** 可自定义新增验证规则**/
                                 "dxMsgFormatSet.cloumEname":{
                                     validators: {
                                         regexp: {
                                             regexp: /^[a-zA-Z\-_.]+$/,
                                              message: '只能是字母'
                                          }
                                      }
                                }

                            }
                        });
                    });
                }
                // function setdataShortName(formId) {
                //     var dataShortName = $("#"+formId).find("input[name='dxMsgFormatSet.cloumEname']").val();
                //     console.log(dataShortName,"fpc");
                //     if (/^[a-z][a-z0-9_]*$/.test(dataShortName)) {
                //         // $("#dataAttr").val(transformStr3(dataShortName));
                //     } else {
                //         // layer.tips('只能小写字母、数字、下划线组合，且开头必须是字母', '#dataShortName', {tips: 3});
                //         $("#dataShortName").val("");
                //         return;
                //     }
                // }


            </script>
        </section>
        <!-- Main end -->
    </div>
    <!-- foot start -->
    <%@include file="/common/dxp/foot.jsp" %>
    <!-- foot start -->
</div>
<!-- /.content-wrapper -->
</body>
</html>















